Skip to content

Revert bumping samsam to v9 to fix buffer comparisons#2681

Closed
mattbaileyuk wants to merge 1 commit intosinonjs:mainfrom
mattbaileyuk:revert-samsam-bump
Closed

Revert bumping samsam to v9 to fix buffer comparisons#2681
mattbaileyuk wants to merge 1 commit intosinonjs:mainfrom
mattbaileyuk:revert-samsam-bump

Conversation

@mattbaileyuk
Copy link
Copy Markdown

Purpose (TL;DR) - mandatory

Fixes #2678

Reverts @sinonjs/samsam to v8 (as used before this commit bumped the package to v9)

Background (Problem in detail)

Given the problems identified in the issue above around Buffer object comparisons (and as raised directly in sinonjs/samsam#289), this moves back to the previous major version of samsam so sinon can successfully do comparisons of Buffer objects.

How to verify - mandatory

  1. Check out this branch
  2. npm install
  3. Follow the reproduce in withArgs stops matching Buffers by content in 21.0.2 (samsam major bump in patch release) #2678

Checklist for author

  • npm run lint passes
  • References to standard library functions are cached.

@fatso83
Copy link
Copy Markdown
Contributor

fatso83 commented Mar 16, 2026

nevermind - wrong issue

@fatso83
Copy link
Copy Markdown
Contributor

fatso83 commented Mar 16, 2026

There will be patch coming today to address the fallout for Buffers in sinonjs/samsam#289

This happened because Buffer.from("Hello") usually does not allocate a fresh backing store for each small buffer.

In the Node runtime, both buffers came from the same pooled parent ArrayBuffer of length 8192, and offset is just the start position of each view into that slab. I verified:

  - sameParent: true
  - parentByteLength: 8192
  - offset1: 8
  - offset2: 16

So the contents are identical, but the internal slice position is different. That offset getter is inherited and enumerable on Buffer.prototype, which is why the change in lib/deep-equal.js#L160 started treating two equal buffers as unequal. offset is allocator metadata, not part of the logical buffer value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

withArgs stops matching Buffers by content in 21.0.2 (samsam major bump in patch release)

2 participants